<script setup lang="ts">
import {CommonTable} from "@/components/MyComponent/CommonTable/tableInterface";
import {RuleInfoType} from "@/api/sys/admin/rule-info/types";
import {
  addRuleInfoApi,
  deleteRuleInfoApi,
  editRuleInfoApi,
  getRuleInfoByIdApi,
  getRuleInfoListApi
} from "@/api/sys/admin/rule-info";

const options: CommonTable<RuleInfoType, RuleInfoType> = {
  api: {
    add: addRuleInfoApi,
    remove: deleteRuleInfoApi,
    edit: editRuleInfoApi,
    get: getRuleInfoByIdApi,
    getList: getRuleInfoListApi
  },
  attrs: [
    {
      prop: 'title',
      label: '标题',
      columnWidth: 140
    }, {
      prop: 'remark',
      label: '描述',
      formType: 'textarea',
      columnWidth: 500,
      sort: false,
      query: false
    }, {
      prop: 'sort',
      label: '排序',
      formType: 'number',
      query: false,
      columnWidth: 80
    }, {
      prop: 'type',
      label: '类型',
      formType: 'select',
      code: 'rule_info_type',
    }, {
      prop: 'status',
      label: '状态',
      formType: 'radio',
      code: 'status',
      columnWidth: 80
    }
  ],
  title: '规则说明',
  perms: {
    add: '',
    edit: '',
    remove: '',
    view: ''
  },
  form: {
    initialForm: {
      id: 0,
      title: '',
      type: 1,
      status: 1,
      remark: '',
      sort: 1
    },
    rules: {
      title: [{required: true, message: '请输入标题', trigger: 'blur'}],
    },
    labelWidth: 80,
  }
}
</script>

<template>
  <x-common-table :options="options"/>
</template>
